package com.kfm.loginIp.util;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

/**
 * @author Aurora雪
 */
public class TencentCredentialsReaderUtil {
    private static final String CONFIG_FILE_PATH = "C:\\Users\\Aurora雪\\.tencentcloud\\credentials.perproties";

//    public static void main(String[] args) {
//        String secretId = getSecretId();
//        String secretKey = getSecretKey();
//        System.out.println("SecretId: " + secretId);
//        System.out.println("SecretKey: " + secretKey);
//    }

    /**
     * 获取SecretId
     *
     * @return SecretId
     */
    public static String getSecretId() {
        Properties properties = new Properties();
        try (FileInputStream inputStream = new FileInputStream(CONFIG_FILE_PATH)) {
            properties.load(inputStream);
            return properties.getProperty("secret_id");
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
    }

    /**
     * 获取SecretKey
     *
     * @return SecretKey
     */
    public static String getSecretKey() {
        Properties properties = new Properties();
        try (FileInputStream inputStream = new FileInputStream(CONFIG_FILE_PATH)) {
            properties.load(inputStream);
            return properties.getProperty("secret_key");
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
    }
}
